home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: 26 June 1997
- // Author: jb
- //
- // Description:
- // This procedure figures out which selection mode the program is in.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // A string containing the name of the selection mode
- //
- //
- // ***********************************************************************
- //
- // Warning:
- // Be sure that any changes made in this file are also reflected in
- // setSelectMode.mel
- //
- // ***********************************************************************
-
- global string $gAllObjects[] = {
- "joint", "light", "camera", "lattice", "cluster", "sculpt", "nonlinear",
- "nurbsCurve","nurbsSurface", "curveOnSurface", "polymesh", "subdiv",
- "plane", "particleShape", "emitter", "field", "fluid",
- "spring", "rigidBody", "rigidConstraint", "xyz", "orientationLocator",
- "dimension", "texture", "locator",
- "handle", "ikHandle"};
-
- global string $gAllComponents[] = {
- "controlVertex", "hull", "editPoint",// "pv", "pe", "pfe", "pf",
- // "puv", "spv", "spe", "spf", "vertex", "edge", "facet",
- "subdivMeshPoint", "subdivMeshEdge", "subdivMeshFace", "subdivMeshUV",
- "curveParameterPoint", "curveKnot",
- "surfaceParameterPoint", "surfaceKnot", "surfaceRange", "surfaceEdge",
- "surfaceFace", "isoparm", "latticePoint", "imagePlane",
- "pr", "springComponent", "jp", "iee", "sp", "rp", "sh"
- //, "lra", "ac", "ak", "ait", "aot"
- };
-
- global string $gAnimationSelectionMasksOn[] = {"joint", "handle", "ikHandle"};
-
- global string $gNURBSelectionMasksObjects[] = {
- "nurbsCurve",
- "nurbsSurface",
- "curveOnSurface",
- "plane",
- "curve"};
-
- global string $gNURBSelectionMasksComponents[] = {
- "curveParameterPoint",
- "surfaceEdge",
- "isoparm",
- "editPoint",
- "controlVertex",
- "hull",
- "surfaceFace"};
-
- global string $gDeformersSelectionMasksObjects[] = {"lattice",
- "cluster",
- "sculpt",
- "nonlinear",
- "nurbsCurve"};
-
- global string $gDeformersSelectionMasksComponents[] = {"latticePoint"};
-
- global string $gRenderingSelectionMasksObjects[] = {
- "light",
- "camera",
- "plane"};
-
- global string $gRenderingSelectionMasksComponents[] = {"imagePlane"};
-
- proc int arrayFind(string $str, string $look[])
- // Search the array for the given string.
- // Return true if found.
- {
- int $i;
-
- for ($i = 0; $i < size($look); $i++) {
- if ($look[$i] == $str) {
- return true;
- }
- }
- return false;
- }
-
- proc string[] pruneArray(string $main[], string $toremove[])
- // Remove the elements of $toremove that occur in $main and return the result
- {
- string $result[];
- int $resultSize = 0;
-
- int $i;
-
- for ($i = 0; $i < size($main); $i++) {
- int $temp = arrayFind($main[$i], $toremove);
- if (!$temp) {
- // print("Not found " + $main[$i] +"\n");
- $result[$resultSize++] = $main[$i];
- }
- }
-
- return $result;
- }
-
- proc int allMasksOff(string $masks[])
- // Check to see if all of the specified selection masks are off.
- // Return true if they are.
- {
- int $i;
-
- int $result = false;
- string $cmd;
-
- // print ("In allMasksOff size is " + size($masks) + "\n");
-
- for ($i = 0; $i < size($masks) && !$result; $i++) {
- $cmd = "selectType -q -" + $masks[$i] + ";";
- $result = eval($cmd);
- // if ($result) {
- // warning ("Flag " + $masks[$i] + " is on.");
- // }
- }
-
- return !$result;
- }
-
- proc int allMasksOn(string $masks[])
- // Check to see if all of the specified selection masks are on.
- // Return true if they are.
- {
- int $i;
-
- int $result = true;
- string $cmd;
-
- // print "In allMasksOn\n";
-
- for ($i = 0; $i < size($masks) && $result; $i++) {
- $cmd = "selectType -q -" + $masks[$i];
- $result = eval($cmd);
- // if (!$result) {
- // warning ("Flag " + $masks[$i] + " is off.");
- // }
- }
-
- return $result;
- }
-
- proc int onlyObjectsOn(string $masks[])
- // Verify that only the specified object selection masks are on.
- {
- int $i;
- global string $gAllObjects[];
-
- string $newMaskList[] = pruneArray($gAllObjects, $masks);
-
- // print ("$newMaskList is of size " + size($newMaskList) + "\n");
-
- int $result = (allMasksOn($masks) &&
- allMasksOff($newMaskList));
-
- return $result;
- }
-
- proc int onlyComponentsOn(string $masks[])
- // Verify that only the specified component selection masks are on.
- {
- int $i;
- global string $gAllComponents[];
-
- string $newMaskList[] = pruneArray($gAllComponents, $masks);
-
- int $result = (allMasksOn($masks) &&
- allMasksOff($newMaskList));
-
- return $result;
- }
-
- global proc string getSelectMode() {
- //
- // Return the string that represents
- // the current high level selection mask
- //
- string $selectionModeName;
- global string $gAllObjects[];
- global string $gAnimationSelectionMasksOn[];
- global string $gNURBSelectionMasksObjects[];
- global string $gNURBSelectionMasksComponents[];
- global string $gDeformersSelectionMasksObjects[];
- global string $gDeformersSelectionMasksComponents[];
- global string $gRenderingSelectionMasksObjects[];
- global string $gRenderingSelectionMasksComponents[];
- if (`selectMode -q -root` ||
- `selectMode -q -leaf` ||
- `selectMode -q -template`)
- {
- $selectionModeName = "Hierarchy";
- }
- else if (`selectMode -q -object`) {
- if (!`selectPref -q -ignoreSelectionPriority` &&
- `selectPriority -q -handle` == 5 &&
- `selectPriority -q -ikHandle` == 5 &&
- `selectPriority -q -joint` == 4 &&
- onlyObjectsOn($gAnimationSelectionMasksOn))
- {
- $selectionModeName = "Animation";
- }
- else if (allMasksOn($gAllObjects) &&
- `selectPref -q -ignoreSelectionPriority`)
- {
- $selectionModeName = "All Objects";
- }
- else {
- $selectionModeName = "Objects";
- }
- } else if (`selectMode -q -component`) {
- if (`selectPref -q -ignoreSelectionPriority` &&
- `selectType -q -polymesh` &&
- `selectType -q -subdiv` &&
- `selectType -q -plane` &&
- allMasksOff($gNURBSelectionMasksComponents) &&
- (`selectType -q -vertex` ||
- `selectType -q -edge` ||
- `selectType -q -facet` ||
- `selectType -q -subdivMeshPoint` ||
- `selectType -q -subdivMeshEdge` ||
- `selectType -q -subdivMeshFace` ||
- `selectType -q -subdivMeshUV`))
- {
- $selectionModeName = "Polygons";
- }
- else {
- $selectionModeName = "Components";
- }
- } else if (`selectMode -q -preset`) {
- if (!`selectPref -q -ignoreSelectionPriority` &&
- !`selectPref -q -allowHiliteSelection` &&
- `selectPriority -q -isoparm` == 2 &&
- onlyObjectsOn($gNURBSelectionMasksObjects) &&
- onlyComponentsOn($gNURBSelectionMasksComponents) )
- {
- $selectionModeName = "NURBS";
- }
- else if (!`selectPref -q -ignoreSelectionPriority` &&
- !`selectPref -q -allowHiliteSelection` &&
- `selectPriority -q -sculpt` == 5 &&
- `selectPriority -q -nonlinear` == 5 &&
- `selectPriority -q -lattice` == 5 &&
- `selectPriority -q -cluster` == 5 &&
- `selectPriority -q -locator` == 5 &&
- onlyObjectsOn($gDeformersSelectionMasksObjects) &&
- onlyComponentsOn($gDeformersSelectionMasksComponents) )
- {
- $selectionModeName = "Deform";
- }
- else if (`selectPref -q -allowHiliteSelection` &&
- `selectType -q -particleShape` &&
- `selectType -q -emitter` &&
- `selectType -q -field` &&
- `selectType -q -fluid` &&
- `selectType -q -collisionModel` &&
- `selectType -q -spring` &&
- `selectType -q -rigidBody` &&
- `selectType -q -rigidConstraint` &&
- `selectType -q -particle` &&
- `selectType -q -springComponent` )
- {
- $selectionModeName = "Dynamics";
- }
- else if (!`selectPref -q -allowHiliteSelection` &&
- onlyObjectsOn($gRenderingSelectionMasksObjects) &&
- onlyComponentsOn($gRenderingSelectionMasksComponents) )
- {
- $selectionModeName = "Rendering";
- }
- else {
- $selectionModeName = "Mixed";
- }
- }
-
- return $selectionModeName;
- }
-